/*
 *      Copyright 2008 Battams, Derek
 *       
 *       Licensed under the Apache License, Version 2.0 (the "License");
 *       you may not use this file except in compliance with the License.
 *       You may obtain a copy of the License at
 *
 *          http://www.apache.org/licenses/LICENSE-2.0
 *
 *       Unless required by applicable law or agreed to in writing, software
 *       distributed under the License is distributed on an "AS IS" BASIS,
 *       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *       See the License for the specific language governing permissions and
 *       limitations under the License.
 */
package com.google.code.gwtsrwc.client;

import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;

/**
 * A simple extension of FlexTable that loads its data cells from a TableModel object
 * @author $Author: derek@battams.ca $
 * @version $Id: LiveFlexTable.java 25 2008-09-09 22:53:35Z derek@battams.ca $
 * $URL: http://gwtsrwc.googlecode.com/svn/trunk/src/com/google/code/gwtsrwc/client/LiveFlexTable.java $
 */
public class LiveFlexTable extends FlexTable {	
	public LiveFlexTable(TableModel<?> model) {
		for(int i = 0; i < model.getColumnCount(); ++i)
			setWidget(0, i, new Label(model.getColumnDescriptor(i).getHeading()));
		for(int i = 0; i < model.getRowCount(); ++i) {
			for(int j = 0; j < model.getColumnCount(); ++j) {
				setWidget(i + 1, j, model.getCell(i, j));
			}
		}
	}
}
